<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>FlyShop开源商城系统 - FlyShop开源电子商务平台</title>
    <meta name='keywords' content='开源商城系统,开源网店系统,开源电子商务,商城系统源码,多用户商城源码'>
    <meta name='description' content='FlyShop是基于Java开发b2c2c开源多用户商城系统,支持商家入驻,支持微商城,手机移动商城,APP商城多为一体的电子商务系统'>
    <link rel="stylesheet" href="/assets/admin-lte/css/admin.css" />
    <!--[if lt IE 9]>
    <script src="/assets/js/html5shiv.min.js"></script>
    <script src="/assets/js/respond.min.js"></script>
    <![endif]-->
    <meta name="robots" content="noindex,nofollow">
    <link rel="shortcut icon" href="/assets/favicon.ico" />
    <script type="text/javascript" charset="UTF-8" src="/assets/js/vendors/jquery/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" charset="UTF-8" src="/assets/js/vendors/artdialog/artDialog.js"></script>
    <script type="text/javascript" charset="UTF-8" src="/assets/js/vendors/artdialog/plugins/iframeTools.js"></script>
    <link rel="stylesheet" type="text/css" href="/assets/js/vendors/artdialog/skins/aero.css" />
    <script type="text/javascript" charset="UTF-8" src="/assets/js/vendors/autovalidate/validate.js"></script>
    <link rel="stylesheet" type="text/css" href="/assets/js/vendors/autovalidate/style.css" />
    <script type="text/javascript" charset="UTF-8" src="/assets/js/vendors/artTemplate/artTemplate.js"></script>
    <script type="text/javascript" charset="UTF-8" src="/assets/js/vendors/artTemplate/artTemplate-plugin.js"></script>
    <script type='text/javascript' src="/assets/js/vendors/bootstrap/js/bootstrap.min.js"></script>
    <script type='text/javascript' src="/assets/admin-lte/js/adminlte.min.js"></script>
</head>
<body class="skin-blue fixed sidebar-mini" style="height: auto; min-height: 100%;">
<div class="wrapper" style="height: auto; min-height: 100%;">
    <header class="main-header">
        <div class="logo">
            <span class="logo-mini"><b>iWeb</b></span>
            <span class="logo-lg"><b>iWebShop</b>后台管理</span>
        </div>
        <nav class="navbar navbar-static-top">
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                <span class="sr-only"></span>
            </a>

            <!--顶部菜单 开始-->
            <div id="menu" class="navbar-custom-menu">
                <ul class="nav navbar-nav" name="topMenu">
                    <li><a hidefocus="true" href="/goods/goods_list">商品</a></li>
                    <li><a hidefocus="true" href="/member/member_list">会员</a></li>
                    <li><a hidefocus="true" href="/order/order_list">订单</a></li>
                    <li><a hidefocus="true" href="/market/pro_rule_list">营销</a></li>
                    <li><a hidefocus="true" href="/market/user_reg">统计</a></li>
                    <li><a hidefocus="true" href="/system/default">系统</a></li>
                    <li><a hidefocus="true" href="/tools/db_bak">工具</a></li>
                    <li><a hidefocus="true" href="/plugins/plugin_list">插件</a></li>
                    <li>
                        <a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
                    </li>
                </ul>
            </div>
            <!--顶部菜单 结束-->
        </nav>
    </header>

    <!--左侧菜单 开始-->
    <aside id="admin_left" class="main-sidebar">
        <section class="sidebar" style="height: auto;">
            <div class="user-panel">
                <div class="pull-left image">
                    <i class="fa fa-user"></i>
                </div>
                <div class="pull-left info">
                    <p>admin</p>
                    <a href="#">超级管理员</a>
                </div>
            </div>

            <ul class="sidebar-menu tree" data-widget="tree">
                <li class="header">系统模块菜单</li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa" name="ico" menu="后台首页"></i>
                        <span>后台首页</span>
                        <span class="pull-right-container">
								<i class="fa fa-angle-left pull-right"></i>
							</span>
                    </a>
                    <ul class="treeview-menu" name="leftMenu">
                        <li><a href="/system/default"><i class="fa fa-circle-o"></i>首页</a></li>
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa" name="ico" menu="网站管理"></i>
                        <span>网站管理</span>
                        <span class="pull-right-container">
								<i class="fa fa-angle-left pull-right"></i>
							</span>
                    </a>
                    <ul class="treeview-menu" name="leftMenu">
                        <li><a href="/system/conf_base"><i class="fa fa-circle-o"></i>网站设置</a></li>
                        <li><a href="/system/conf_guide"><i class="fa fa-circle-o"></i>网站导航</a></li>
                        <li><a href="/system/conf_banner"><i class="fa fa-circle-o"></i>首页幻灯图</a></li>
                        <li><a href="/system/conf_ui/type/site"><i class="fa fa-circle-o"></i>网站前台主题</a></li>
                        <li><a href="/system/conf_ui/type/system"><i class="fa fa-circle-o"></i>后台管理主题</a></li>
                        <li><a href="/system/conf_ui/type/seller"><i class="fa fa-circle-o"></i>商家管理主题</a></li>
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa" name="ico" menu="支付管理"></i>
                        <span>支付管理</span>
                        <span class="pull-right-container">
								<i class="fa fa-angle-left pull-right"></i>
							</span>
                    </a>
                    <ul class="treeview-menu" name="leftMenu">
                        <li><a href="/system/payment_list"><i class="fa fa-circle-o"></i>支付方式</a></li>
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa" name="ico" menu="第三方平台"></i>
                        <span>第三方平台</span>
                        <span class="pull-right-container">
								<i class="fa fa-angle-left pull-right"></i>
							</span>
                    </a>
                    <ul class="treeview-menu" name="leftMenu">
                        <li><a href="/system/oauth_list"><i class="fa fa-circle-o"></i>oauth登录列表</a></li>
                        <li><a href="/system/hsms"><i class="fa fa-circle-o"></i>手机短信平台</a></li>
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa" name="ico" menu="配送管理"></i>
                        <span>配送管理</span>
                        <span class="pull-right-container">
								<i class="fa fa-angle-left pull-right"></i>
							</span>
                    </a>
                    <ul class="treeview-menu" name="leftMenu">
                        <li><a href="/system/delivery"><i class="fa fa-circle-o"></i>配送方式</a></li>
                        <li><a href="/system/freight_list"><i class="fa fa-circle-o"></i>物流公司</a></li>
                        <li><a href="/system/takeself_list"><i class="fa fa-circle-o"></i>自提点列表</a></li>
                        <li><a href="/system/takeself_edit"><i class="fa fa-circle-o"></i>添加自提点</a></li>
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa" name="ico" menu="地域管理"></i>
                        <span>地域管理</span>
                        <span class="pull-right-container">
								<i class="fa fa-angle-left pull-right"></i>
							</span>
                    </a>
                    <ul class="treeview-menu" name="leftMenu">
                        <li><a href="/system/area_list"><i class="fa fa-circle-o"></i>地区列表</a></li>
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa" name="ico" menu="权限管理"></i>
                        <span>权限管理</span>
                        <span class="pull-right-container">
								<i class="fa fa-angle-left pull-right"></i>
							</span>
                    </a>
                    <ul class="treeview-menu" name="leftMenu">
                        <li><a href="/system/admin_list"><i class="fa fa-circle-o"></i>管理员</a></li>
                        <li><a href="/system/role_list"><i class="fa fa-circle-o"></i>角色</a></li>
                        <li><a href="/system/right_list"><i class="fa fa-circle-o"></i>权限资源</a></li>
                    </ul>
                </li>

                <li class="header">快速导航</li>
                <li><a href="fdfdsf"><i class="fa fa-star-o"></i> <span>aaa</span></a></li>
            </ul>
        </section>
    </aside>
    <!--左侧菜单 结束-->

    <!--右侧内容 开始-->
    <div id="admin_right" class="content-wrapper">
        <script type="text/javascript" charset="UTF-8" src="/runtime/_systemjs/artTemplate/artTemplate.js"></script><script type="text/javascript" charset="UTF-8" src="/runtime/_systemjs/artTemplate/artTemplate-plugin.js"></script>
        <div class="breadcrumbs" id="breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="home-icon fa fa-home"></i>
                    <a href="#">系统</a>
                </li>
                <li>
                    <a href="#">地域管理</a>
                </li>
                <li class="active">地区列表</li>
            </ul>
        </div>
        <div class="content">
            <table class="table list-table">
                <colgroup>
                    <col  />
                    <col width="160px"/>
                    <col width="120px">
                </colgroup>
                <caption>
                    <a class="btn btn-default" onclick="addArea(0,0);">
                        <i class="fa fa-plus"></i>添加地区
                    </a>
                </caption>
                <thead>
                <tr>
                    <th>名称</th>
                    <th>排序</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="area_box"></tbody>
            </table>
        </div>

        <!--地域模板 开始-->
        <script type='text/html' id='areaRowTemplate'>
            <tr id="area_<%=item['area_id']%>" name="parent_<%=item['parent_id']%>">
                <td <%if(level > 0){%>style="padding-left:<%=level*30%>px"<%}%>>
                <a href="javascript:toggleArea(<%=item['area_id']%>,<%=level+1%>);"><i id="ctrl_<%=item['area_id']%>" name="box_<%=item['parent_id']%>" class="operator fa fa-plus-square-o" is_open="no" is_cache="no"></i></a>
                <input type="text" value="<%=item['area_name']%>" name="area_name" class="form-control w-auto" style="width:150px" onblur="updateArea(<%=item['area_id']%>,this);" />
                </td>
                <td><input type="text" value="<%=item['sort']%>" name="area_sort" class="form-control w-auto" style="width:80px" onblur="updateArea(<%=item['area_id']%>,this);" /></td>
                <td>
                    <a href="javascript:addArea(<%=item['area_id']%>,<%=level+1%>);"><i class='operator fa fa-plus'></i></a>
                    <a href="javascript:delArea(<%=item['area_id']%>);"><i class='operator fa fa-close'></i></a>
                </td>
            </tr>
        </script>
        <!--地域模板 结束-->

        <script type='text/javascript'>
            //DOM加载完毕后
            $(function()
            {
                var firstData = [{"area_id":"110000","parent_id":"0","area_name":"北京市","sort":"110000"},{"area_id":"120000","parent_id":"0","area_name":"天津市","sort":"120000"},{"area_id":"130000","parent_id":"0","area_name":"河北省","sort":"130000"},{"area_id":"140000","parent_id":"0","area_name":"山西","sort":"140000"},{"area_id":"150000","parent_id":"0","area_name":"内蒙古自治区","sort":"150000"},{"area_id":"210000","parent_id":"0","area_name":"辽宁省","sort":"210000"},{"area_id":"220000","parent_id":"0","area_name":"吉林省","sort":"220000"},{"area_id":"230000","parent_id":"0","area_name":"黑龙江省","sort":"230000"},{"area_id":"310000","parent_id":"0","area_name":"上海市","sort":"310000"},{"area_id":"320000","parent_id":"0","area_name":"江苏省","sort":"320000"},{"area_id":"330000","parent_id":"0","area_name":"浙江省","sort":"330000"},{"area_id":"340000","parent_id":"0","area_name":"安徽省","sort":"340000"},{"area_id":"350000","parent_id":"0","area_name":"福建省","sort":"350000"},{"area_id":"360000","parent_id":"0","area_name":"江西省","sort":"360000"},{"area_id":"370000","parent_id":"0","area_name":"山东省","sort":"370000"},{"area_id":"410000","parent_id":"0","area_name":"河南省","sort":"410000"},{"area_id":"420000","parent_id":"0","area_name":"湖北省","sort":"420000"},{"area_id":"430000","parent_id":"0","area_name":"湖南省","sort":"430000"},{"area_id":"440000","parent_id":"0","area_name":"广东省","sort":"440000"},{"area_id":"450000","parent_id":"0","area_name":"广西壮族自治区","sort":"450000"},{"area_id":"460000","parent_id":"0","area_name":"海南省","sort":"460000"},{"area_id":"500000","parent_id":"0","area_name":"重庆市","sort":"500000"},{"area_id":"510000","parent_id":"0","area_name":"四川省","sort":"510000"},{"area_id":"520000","parent_id":"0","area_name":"贵州省","sort":"520000"},{"area_id":"530000","parent_id":"0","area_name":"云南省","sort":"530000"},{"area_id":"540000","parent_id":"0","area_name":"西藏自治区","sort":"540000"},{"area_id":"610000","parent_id":"0","area_name":"陕西省","sort":"610000"},{"area_id":"620000","parent_id":"0","area_name":"甘肃省","sort":"620000"},{"area_id":"630000","parent_id":"0","area_name":"青海省","sort":"630000"},{"area_id":"640000","parent_id":"0","area_name":"宁夏回族自治区","sort":"640000"},{"area_id":"650000","parent_id":"0","area_name":"新疆维吾尔自治区","sort":"650000"},{"area_id":"710000","parent_id":"0","area_name":"台湾省","sort":"710000"},{"area_id":"810000","parent_id":"0","area_name":"香港特别行政区","sort":"810000"},{"area_id":"820000","parent_id":"0","area_name":"澳门特别行政区","sort":"820000"}];
                for(var item in firstData)
                {
                    $('#area_box').append(template.render('areaRowTemplate',{'item':firstData[item],'level':0}));
                }
            });

            //切换地区
            function toggleArea(area_id,level)
            {
                var is_cache = $('#ctrl_'+area_id).attr('is_cache');
                var is_open  = $('#ctrl_'+area_id).attr('is_open');

                //缓存存在
                if(is_cache == 'yes')
                {
                    $('[name="parent_'+area_id+'"]').toggle();
                }
                else
                {
                    $.getJSON('/block/area_child',{"aid":area_id},function(jsonData){
                        for(var item in jsonData)
                        {
                            $('#area_'+area_id).after(template.render('areaRowTemplate',{'item':jsonData[item],'level':level}));
                        }
                    });
                    $('#ctrl_'+area_id).attr('is_cache','yes');
                }

                //是否已经展开
                if(is_open == 'yes')
                {
                    $('#ctrl_'+area_id).removeClass("fa-minus-square-o").addClass("fa-plus-square-o");
                    $('#ctrl_'+area_id).attr('is_open','no');

                    //递归子分类
                    $("img[name='box_"+area_id+"'][is_open='yes']").each(function()
                    {
                        var idValue = $(this).attr('id').replace("ctrl_","");
                        toggleArea(idValue);
                    });
                }
                else
                {
                    $('#ctrl_'+area_id).removeClass("fa-plus-square-o").addClass("fa-minus-square-o");
                    $('#ctrl_'+area_id).attr('is_open','yes');
                }
            }

            //添加地区
            function addArea(area_id,level)
            {
                art.dialog.prompt('添加新地域',function(area_name){
                    if(!area_name)
                    {
                        alert('请填写地域名称');
                        return;
                    }
                    $.getJSON("/system/area_update",{"parent_id":area_id,"area_name":area_name},function(result){
                        if(result.isSuccess == true)
                        {
                            if(area_id == 0)
                            {
                                window.location.reload();
                                return;
                            }

                            var is_open  = $('#ctrl_'+area_id).attr('is_open');
                            if(is_open == 'yes')
                            {
                                $('#area_'+area_id).after(template.render('areaRowTemplate',{'item':result.data,'level':level}));
                            }
                            else
                            {
                                toggleArea(area_id,level);
                            }
                        }
                    });
                });
            }

            //删除地区
            function delArea(area_id)
            {
                art.dialog.confirm('确定要删除么？',function(){
                    $.get('/system/area_del',{'id':area_id},function(result){$('#area_'+area_id).remove();})
                });
            }

            //更新地域数据
            function updateArea(area_id,obj)
            {
                if($.trim(obj.value) == '')
                {
                    alert('地域信息不能为空');
                    return;
                }

                var sendData = {"area_id":area_id};
                switch(obj.name)
                {
                    case "area_sort":
                    {
                        sendData.area_sort = obj.value;
                    }
                        break;

                    default:
                    {
                        sendData.area_name = obj.value;
                    }
                        break;
                }
                $.getJSON('/system/area_update',sendData,function(result){});
            }
        </script>

    </div>
    <!--右侧内容 结束-->

    <!--顶部弹出菜单 开始-->
    <aside class="control-sidebar control-sidebar-dark">
        <ul class="control-sidebar-menu">
            <li><a href="/admin/logout"><i class="fa fa-circle-o text-red"></i> 退出管理</a></li>
            <li><a href="/system/admin_repwd"><i class="fa fa-circle-o text-yellow"></i> 修改密码</a></li>
            <li><a href="/system/default"><i class="fa fa-circle-o text-green"></i> 后台首页</a></li>
            <li><a href="/" target='_blank'><i class="fa fa-circle-o text-aqua"></i> 商城首页</a></li>
            <li><a href="/system/navigation"><i class="fa fa-circle-o"></i> 快速导航</a></li>
        </ul>
    </aside>
    <!--顶部弹出菜单 结束-->
</div>
</body>
</html>